
<template>
  <base-page-view class-name="page-container box-page boxDetails_page">
    <base-nav v-if="!isHide" title="" class="boxDetails_nav">
      <view slot="left" @click="handelBack">
        <image class="header-left" src="/static/images/icon/icon_arror_left.png" />
      </view>
      <view slot="title">
        <view class="title_nav">{{ navTitle }}</view>
      </view>
    </base-nav>
    <view class="directCount">{{ '活动直接参与人数（'+directChildCount+'人）' }}</view>
    <view>
      <view v-for="(item,index) in list" :key="index" class="directList">
        <view class="direct_left">
          <image src="/static/images/mine/touxiang.png" class="directList_img" />
          <view>
            <view class="nickname">{{ item.nickname }}</view>
            <view>手机号：{{ item.mobile.substring(0,3)+'****'+item.mobile.substring(item.mobile.length-4,item.mobile.length) }}</view>
          </view>
        </view>
        <view>
          <view>箱数：<span class="blod_span">{{ item.number }}</span></view>
          <view v-if="item.reward >= 0">奖励：<span class="blod_span">{{ item.reward | formatMoney }}</span></view>
          <view v-else>奖励：<span class="blod_span totalPriceRed">{{ Math.abs(item.reward) | formatMoney }}</span></view>
        </view>
      </view>
    </view>
    <view v-if="nomore&&list.length>0" class="nomore">暂无更多数据~</view>
    <view v-if="list.length<1&&nomore" class="empty_view">
      <image src="/static/images/commission/commission-empty.png" class="empty_img" />
      <view class="tit">暂无任何内容</view>
    </view>
  </base-page-view>
</template>

<script>
import './index.scss'
import { inApp } from '@/utils/tools'
export default {
  components: {
  },
  data() {
    return {
      list: [],
      monthValue: '',
      directChildCount: 0,
      boxDetails: {
        number: 0,
        familyNumber: 0,
        reward: 0,
        familyReward: 0,
        directChildCount: 0
      },
      pageNo: 1,
      pageSize: 10,
      nomore: false,
      ruleId: '',
      navTitle: '活动参与人数',
      datePickValue: ''
    }
  },
  computed: {
    isHide() {
      return inApp()
    }
  },
  created() {

  },
  onLoad(option) {
    this.ruleId = option.ruleId
    this.monthValue = option.monthValue
    this.directChildCount = option.directChildCount
    this.initData()
  },
  onPullDownRefresh() {
    this.pageNo = 1
    this.list = []
    this.nomore = false
    this.initData()
  },
  onReachBottom() {
    if (this.nomore) return
    this.pageNo += 1
    this.getList()
  },
  onShow() {
  },
  methods: {
    async initData() {
      this.getList()
    },
    async getList() {
      const directList = await this.$api.commissionApi.getDirectChildRewardInfoListByUserId({
        ruleId: this.ruleId,
        monthValue: this.monthValue,
        userId: this.$store.state.userInfo.uid,
        pageSize: this.pageSize,
        pageNo: this.pageNo })
      if (directList.code === '000000') {
        setTimeout(function() {
          uni.stopPullDownRefresh()
        }, 500)
        this.list = this.list.concat(directList.data)
        if (directList.data.length < this.pageSize) {
          this.nomore = true
        }
      }
    },
    handelBack() {
      uni.navigateBack()
    }
  }
}
</script>
